// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VeLine from 'v-charts/lib/line.common'
// require("./lib/component/title");
import App from './App'
import router from './router'
import store from './store' // vuex
import '@/assets/css/reset.css'
import 'v-charts/lib/style.css'
import VueLazyload from 'vue-lazyload'
import i18n from './lang/index'

// router.beforeEach((to, from, next) => {
//   if(to.path == '/home/material'){
//     next({ path: '/404' })
//   }else{
//     next()
//   }
// })

Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
});
Vue.component(VeLine.name, VeLine)
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: require('./assets/img/error.gif'),
  loading: require('./assets/img/loading.jpeg'),
  attempt: 1
})

Vue.config.productionTip = false

Vue.filter('dateFormat', function(dateStr, pattern=""){
  var dt = new Date(dateStr)
  var y = dt.getFullYear()
  var m = (dt.getMonth() + 1).toString().padStart(2, '0')
  var d = dt.getDate().toString().padStart(2, '0')
  if (pattern.toLowerCase() === 'yyyy-mm-dd') {
    return `${y}-${m}-${d}`
  } else {
    var hh = dt.getHours().toString().padStart(2, '0')
    var mm = dt.getMinutes().toString().padStart(2, '0')
    var ss = dt.getSeconds().toString().padStart(2, '0')

    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
})
// console.log(store.state.myToken)

  



/* eslint-disable no-new */
new Vue({
  el: '#app',
  i18n,
  router,
  store,
  components: { App },
  template: '<App/>'
})
